package Verifier.ArithmeticSystem;

import java.math.BigInteger;

public class FieldTester{
	/* testing Field */
	public static void testField() throws Exception{
		BigInteger fieldNumber = new BigInteger("3");
		Field f = new Field(fieldNumber);
		System.out.println("field order of f: " + f.getOrder());
		
		BigInteger fieldNumberHelp = new BigInteger("5");
		Field fHelp = new Field(fieldNumberHelp);
		System.out.println("field order of fHelp: " + fHelp.getOrder());
		if (fHelp.equals(f))
			System.out.println("equal.");
		else
			System.out.println("not equal.");
		
		BigInteger negative = new BigInteger("-1");
		Field fNegative = new Field(negative);
		System.out.println("field order of fNegative: " + f.getOrder());
		if (fNegative.equals(fHelp))
			System.out.println("equal.");
		else
			System.out.println("not equal.");
	}
	
	/* testing FieldElement */
	public static void testFieldElement() throws Exception{
		BigInteger num = new BigInteger("3");
		BigInteger num2 = new BigInteger("5");
		Field f = new Field(num2);
		FieldElement e = new FieldElement(num, f);
		BigInteger num3 = e.getElement();
		System.out.println("the element is: " + num3);
		Field f2 = e.getField();
		System.out.println("the field of the element is: " + f2.getOrder());
		
		//BigInteger fieldOrder = new BigInteger("3");
		//Field newF = new Field(fieldOrder);
		BigInteger num4 = new BigInteger("4");
		FieldElement e2 = new FieldElement(num4, f2);
		
		FieldElement addition = e.add(e2);
		System.out.println("the element after the addition of " + e.getElement() + " and "
				+ e2.getElement() + " is: " + addition.getElement());
		
		FieldElement multiplication = e.multiply(e2);
		System.out.println("the element after the multiplication of " + e.getElement() + " and "
				+ e2.getElement() + " is: " + multiplication.getElement());
		
		BigInteger num5 = new BigInteger("2");
		FieldElement powerup = e.power(num5);
		System.out.println("the element after the power of " + e.getElement() + " and "
				+ num5 + " is: " + powerup.getElement());
		
		Field fi = e.getField();
		BigInteger el = e.getElement();
		FieldElement fe = new FieldElement(el, fi);
		if (e.equals(fe))
			System.out.println("equal.");
		else
			System.out.println("not equal.");
	}
	
	public static void main(String[] args) throws Exception{
		testField();
		testFieldElement();
		return;
	}
}
